package com.example.werewolf.common;

import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Getter
public enum ActionType {
    WEREWOLF_KILL("狼人行动", "狼人", false, "狼人会议，并给出刀人选择"),
    WITCH_ACTION("女巫行动", "女巫", false, "女巫根据信息，选择使用毒药毒人或使用解药救人"),
    PROPHET_CHECK("预言家行动", "预言家", false, "根据以往的查验信息和对话信息，选择查验玩家身份底牌"),
    RALLY("上警举手", "全体", true, "全部成员都可以选择上警或不上警操作"),
    SPEECH("依次发言", "存活玩家", true, "按照规定的顺序依次发言"),
    EXILE_VOTE("放逐投票", "存活玩家", true, "根据自己了解的分析和角色的玩法，队友的配合，给出放逐投票"),
    CHIEF_VOTE("投票警长", "警下玩家", true, "作为警下玩家，根据阵营玩法和了解到的发言，给出最适合的警长投票");

    private final String description;
    private final String playerType;
    private final Boolean isPublish;
    private final String content;

    ActionType(String description, String playerType, Boolean isPublish, String content) {
        this.description = description;
        this.playerType = playerType;
        this.isPublish = isPublish;
        this.content = content;
    }

    private static final Map<String, ActionType> DESCRIPTION_MAP =
            Arrays.stream(values())
                    .collect(Collectors.toMap(ActionType::getDescription, Function.identity()));

    public static ActionType fromDescription(String description) {
        ActionType actionType = DESCRIPTION_MAP.get(description);
        if (actionType == null) {
            throw new IllegalArgumentException("No ActionType found for description: " + description);
        }
        return actionType;
    }
}
